package com.example.dml.singleton_pattern;

/**
 * @description: 懒加载，使用synchronized关键字增加线程安全
 * @author: gaoyang
 * @date: 2021/10/23 10:12
 */
public class LazySimpleSingleton {

    private LazySimpleSingleton(){}
    //静态块，公共内存区域
    private static LazySimpleSingleton lazy =null;

    public synchronized static LazySimpleSingleton getInstance(){
        if (lazy==null){
            lazy = new LazySimpleSingleton();
        }
        return lazy;
    }
}
